package com.snopy.base.service.impl;

import com.snopy.base.mapper.BaseMapper;
import com.snopy.base.pojo.Carousel;
import com.snopy.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname CarouselServiceImpl
 * @description
 * @email 77912204@qq.com
 * @date 2022/08/12 10:25
 */
public class BaseServiceImpl implements BaseService {

    @Autowired
    private BaseMapper baseMapper;
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Carousel> queryAll(Integer isShow) {
        Example example = new Example(Carousel.class);
        example.orderBy("sort").desc();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("isShow", isShow);

        List<Carousel> result =  baseMapper.selectByExample(example);

        return result;
    }
}
